﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

using Newtonsoft.Json;
using WpfApp4.Models;

namespace WpfApp4.Models.Config
{
    public class MenuConfigDTO
    {
        public MenuConfigDTO()
        {
            Parent = null;

            Id = Guid.NewGuid().ToString();
            Name = string.Empty;
            Command = string.Empty;
            CommandParameter = string.Empty;
            WindowSize = string.Empty;
            OpenModel = OpenModel.CurrentWindow;
            MenuItems = new ObservableCollection<MenuConfigDTO> { };
        }


        public MenuConfigDTO Parent { get; set; }

        public string Id { get; set; }

        public string Name { get; set; }

        public string Command { get; set; }

        public string CommandParameter { get; set; }

        public string WindowSize { get; set; }

        public OpenModel OpenModel { get; set; }

        public ObservableCollection<MenuConfigDTO> MenuItems { get; set; }


        public MenuConfigDTO Clone()
        {
            return new MenuConfigDTO()
            {
                Id = this.Id,
                Name = this.Name,
                Command = this.Command,
                CommandParameter = this.CommandParameter,
                WindowSize = this.WindowSize,
                OpenModel = this.OpenModel,
                MenuItems = new ObservableCollection<MenuConfigDTO>(this.MenuItems.Select(x => x.Clone()).ToArray() ?? new MenuConfigDTO[] { }),
            };
        }
    }

    public enum OpenModel : int
    {
        [Description("当前窗口")]
        CurrentWindow = 1,

        [Description("新窗口")]
        NewWindow = 2,
    }
}
